package Demo1;

import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-07-12
 * Time: 11:45
 */
public class Test {
//    public int pop(){
//        if(isEmpty()){
//
//        }else{
//            return elem[--useSize];
//        }
//    }
//    public int peek(){
//        if(isEmpty()){
//
//        }else{
//            return elem[useSize];
//        }
//    }
//    public boolean isEmpty(){
//        return useSize == 0;
//    }

    public boolean IsPopOrder(int[] pushV ,int[] popV){
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for (int i = 0; i < pushV.length; i++) {
            //压栈
            stack.push(pushV[i]);
            while(!stack.empty() && j < popV.length && stack.peek() == popV[j++]){
                stack.pop();
            }
        }
        return stack.empty();
    }
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(1);
        stack.push(2);
        stack.push(3);
//        System.out.println(stack.peek());
//        System.out.println(stack.peek());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
    }
}
